{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "690f7ef7-9506-46fd-b9b8-f19dbc00ab23",
   "metadata": {},
   "source": [
    "# Semantic Memory"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "a1e0edc5-6096-4e6a-a107-d5e7588e897a",
   "metadata": {},
   "outputs": [],
   "source": [
    "# %pip install -U langmem langgraph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "778e3a73-afba-4faf-83f2-715885149ffa",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langgraph.prebuilt import create_react_agent\n",
    "from langgraph.checkpoint.memory import InMemorySaver\n",
    "from langgraph.store.memory import InMemoryStore\n",
    "\n",
    "checkpointer = InMemorySaver()\n",
    "store = InMemoryStore()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "c3a7d7e7-907d-490f-a568-3c4bf4790467",
   "metadata": {},
   "outputs": [],
   "source": [
    "agent = create_react_agent(\"anthropic:claude-3-5-sonnet-latest\", tools=[], store=store, checkpointer=checkpointer)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "7908d3b6-da10-497d-992c-77e6439d832f",
   "metadata": {},
   "outputs": [],
   "source": [
    "def chat(agent, txt, thread_id):\n",
    "    result_state = agent.invoke({\"messages\": [{\"role\": \"user\", \"content\": txt}]}, config={\"configurable\": {\"thread_id\": thread_id}})\n",
    "    return result_state[\"messages\"][-1].content"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "a4e8d540-4f64-417d-9f65-27abc4b06f4f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"Here's a 8-week half marathon training plan, assuming you can already run at least 3-4 miles comfortably:\\n\\nWeek 1-2:\\n- Monday: 3 miles easy pace\\n- Tuesday: Cross-training/rest\\n- Wednesday: 4 miles with intervals (alternate between 1 min fast, 2 min recovery)\\n- Thursday: Rest or light cross-training\\n- Friday: 3 miles easy pace\\n- Saturday: 5-6 miles long run\\n- Sunday: Rest or light cross-training\\n\\nWeek 3-4:\\n- Monday: 4 miles easy pace\\n- Tuesday: Cross-training/rest\\n- Wednesday: 5 miles with tempo runs (middle 2 miles at faster pace)\\n- Thursday: Rest or light cross-training\\n- Friday: 4 miles easy pace\\n- Saturday: 7-8 miles long run\\n- Sunday: Rest or light cross-training\\n\\nWeek 5-6:\\n- Monday: 5 miles easy pace\\n- Tuesday: Cross-training/rest\\n- Wednesday: 6 miles with hills or speed work\\n- Thursday: Rest or light cross-training\\n- Friday: 4 miles easy pace\\n- Saturday: 9-10 miles long run\\n- Sunday: Rest or light cross-training\\n\\nWeek 7-8:\\n- Monday: 5 miles easy pace\\n- Tuesday: Cross-training/rest\\n- Wednesday: 6-7 miles with tempo runs\\n- Thursday: Rest or light cross-training\\n- Friday: 4 miles easy pace\\n- Saturday: 11-12 miles long run (taper in final week)\\n- Sunday: Rest or light cross-training\\n\\nAdditional tips:\\n1. Stay hydrated\\n2. Incorporate stretching\\n3. Get proper running shoes\\n4. Listen to your body and adjust as needed\\n5. Cross-training can include swimming, cycling, or strength training\\n\\nWould you like more specific details about any part of this plan?\""
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "thread_1 = \"thread-1\"\n",
    "chat(agent, \"Hi there, I'm training for a half marathon in 2 months - could you propose a daily training plan to prepare?\", thread_1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "c8289d65-440c-4bcd-959d-f160842b0d6f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"Good luck! You've got this! 💪 Remember to trust your training, pace yourself, and enjoy the journey. Let those endorphins flow and celebrate every milestone along the way. You're going to crush that half marathon! 🏃\\u200d♂️🏃\\u200d♀️🏅\""
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chat(agent, \"Nice! Wish me luck!\", thread_1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ea8b8907-9ee2-4969-836a-f32600a7d6ae",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Just trying to help! Let me know if you have any other questions.'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "thread_2 = \"thread-2\"\n",
    "chat(agent, \"Nice! Oh thank you! It'll be hard.\", thread_2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c5a26b13-e646-4a26-b289-a9b485b755e4",
   "metadata": {},
   "source": [
    "## Adding Memory\n",
    "\n",
    "We'll use regular tools."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "7daf1c41-7fe8-4c79-8b6c-3a8fb7995ee9",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/wfh/.pyenv/versions/3.11.2/lib/python3.11/site-packages/langgraph/store/base/embed.py:95: LangChainBetaWarning: The function `init_embeddings` is in beta. It is actively being worked on, so the API may change.\n",
      "  return init_embeddings(embed)\n"
     ]
    }
   ],
   "source": [
    "from langmem import create_manage_memory_tool, create_search_memory_tool\n",
    "\n",
    "store = InMemoryStore(\n",
    "    index={\n",
    "        \"dims\": 1536,\n",
    "        \"embed\": \"openai:text-embedding-3-small\"\n",
    "    }\n",
    ")\n",
    "\n",
    "namespace = (\"agent_memories\",)\n",
    "memory_tools = [\n",
    "    create_manage_memory_tool(namespace),\n",
    "    create_search_memory_tool(namespace)\n",
    "]\n",
    "checkpointer = InMemorySaver()\n",
    "agent = create_react_agent(\"anthropic:claude-3-5-sonnet-latest\", tools=memory_tools, store=store, checkpointer=checkpointer)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "e4edaea7-5554-4b12-af49-08e423b04577",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"I've created a comprehensive 2-month training plan for your half marathon preparation. This plan assumes you can already run at least 3 miles comfortably. If you're starting from a lower base, please let me know and we can adjust the plan accordingly.\\n\\nThe plan includes:\\n1. Progressive mileage buildup\\n2. Various types of runs (easy, tempo, intervals, long runs)\\n3. Rest days and cross-training\\n4. Taper period before race day\\n5. Important guidelines for pacing and general tips\\n\\nKey features of this plan:\\n- Three running days during the week\\n- One long run on weekends\\n- Two rest/cross-training days\\n- One optional rest/cross-training day\\n- Gradual increase in long run distance\\n- Proper taper week before the race\\n\\nWould you like me to:\\n1. Adjust the mileage based on your current fitness level?\\n2. Provide more specific details about any aspect of the training?\\n3. Add specific pace targets based on your current running ability?\\n\\nAlso, please let me know if you have any existing injuries or conditions that we should take into account to modify the plan accordingly.\""
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "thread_1 = \"thread-1\"\n",
    "chat(agent, \"Hi there, I'm training for a half marathon in 2 months - could you propose a daily training plan to prepare?\", thread_1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "3c4b037a-ab09-43fb-addf-1969af81988d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Perfect! I've stored both your detailed training plan and a note about your goal and enthusiasm. Both memories are now saved and can be referenced in future conversations. The training plan includes all the weekly schedules, pacing guidelines, and important tips, while the second memory captures your timeline and positive attitude toward the goal.\n",
      "\n",
      "Best of luck with your training! Feel free to check back in anytime if you need modifications to the plan or have any questions as you progress through your training journey. Remember to start gradually and listen to your body as you work through the program!\n"
     ]
    }
   ],
   "source": [
    "print(chat(agent, \"Nice! Wish me luck! Please note down the detailed memories for me :)\", thread_1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "479d3c7d-7ee1-46b4-ad6f-3ee849644575",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Yes, I found your training schedule! For Week 3, here\\'s what you\\'re supposed to do:\\n\\nMonday: 4-mile easy run\\nTuesday: Cross-training or rest\\nWednesday: 5-mile run with intervals\\nThursday: Rest or light cross-training\\nFriday: 4-mile tempo run\\nSaturday: 7-mile long run\\nSunday: Rest or light walking\\n\\nRemember:\\n- Easy runs should be at a conversational pace\\n- Tempo runs should be at a \"comfortably hard\" pace\\n- Long runs should be at an easy, conversational pace\\n- Intervals should alternate between hard effort and recovery periods\\n- Stay hydrated and listen to your body\\n\\nWould you like me to remember any specific modifications or notes about how your training is going?'"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "thread_2 = \"thread-2\"\n",
    "chat(agent, \"Remember what I'm supposed to do for my training this week? It's week 3...\", thread_2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "9ea0cfb5-4fdb-4680-9c34-7eec063acbf5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"I've updated your training plan, specifically modifying weeks 3-4 to focus on low-impact activities while your ankle heals. The new plan for this week (Week 3) replaces running with alternative cardio activities:\\n\\n- Monday: Low-impact cross-training (swimming or cycling)\\n- Tuesday: Upper body strength training + Physical therapy exercises\\n- Wednesday: Pool running or cycling intervals\\n- Thursday: Rest + ankle rehabilitation exercises\\n- Friday: Stationary bike or elliptical (30-45 minutes)\\n- Saturday: Long session swimming or cycling (45-60 minutes)\\n- Sunday: Rest + gentle ankle mobility work\\n\\nI've also added injury-specific notes to the plan. Remember to:\\n1. Consult with a healthcare provider before returning to running\\n2. Follow the RICE protocol for your ankle\\n3. Only resume running when you're cleared and pain-free\\n\\nWould you like any clarification about the modified activities or additional adjustments to the plan?\""
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chat(agent, \"That may be tricky. I just sprained my ankle. Could you update my plan to include more cross training? Be sure to update the existing key of our plan\", thread_2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8f562a4e-0ec5-4c70-8027-7791813ec644",
   "metadata": {},
   "source": [
    "## Different User Memories"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "2fba9529-1118-441b-941e-35ed2d127949",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langmem import create_manage_memory_tool, create_search_memory_tool\n",
    "\n",
    "store = InMemoryStore(\n",
    "    index={\n",
    "        \"dims\": 1536,\n",
    "        \"embed\": \"openai:text-embedding-3-small\"\n",
    "    }\n",
    ")\n",
    "\n",
    "namespace = (\"agent_memories\", \"{user_id}\")\n",
    "memory_tools = [\n",
    "    create_manage_memory_tool(namespace),\n",
    "    create_search_memory_tool(namespace)\n",
    "]\n",
    "checkpointer = InMemorySaver()\n",
    "\n",
    "agent = create_react_agent(\"anthropic:claude-3-5-sonnet-latest\", tools=memory_tools, store=store, checkpointer=checkpointer)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "e1736845-41f7-4ce3-8aec-436e18c8add3",
   "metadata": {},
   "outputs": [],
   "source": [
    "def chat(agent, txt, thread_id, user_id):\n",
    "    result_state = agent.invoke({\"messages\": [{\"role\": \"user\", \"content\": txt}]}, \n",
    "                                config={\"configurable\": {\"thread_id\": thread_id, \"user_id\": user_id}})\n",
    "    return result_state[\"messages\"][-1].content"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "fa459758-3241-46b7-a1cc-38ee513d9db2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"I've created a progressive 8-week training plan that will help you prepare for your half marathon. To help you stay accountable, you can check in with me regularly, and I'll be able to recall your training plan and progress. I can:\\n\\n1. Answer questions about specific training days\\n2. Help you adjust the plan if needed\\n3. Provide tips for specific aspects of training\\n4. Track your progress and achievements\\n5. Offer motivation and reminders\\n\\nWould you like me to help you with any specific aspect of the training plan? Also, it would be helpful to know:\\n- Your current running experience/fitness level\\n- Any previous running injuries or concerns\\n- Your target finish time (if you have one)\\n\\nThis information would help me provide more personalized advice and potentially adjust the training plan to better suit your needs.\""
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "thread_1 = \"thread-1\"\n",
    "user_id = \"User-A\"\n",
    "chat(agent, \n",
    "     \"Hi I'm Will, I'm training for a half marathon in 2 months - could you propose a daily training plan to prepare and help me stay honest??\",\n",
    "     thread_1,\n",
    "     user_id)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "8ea8e615-58eb-4b02-9084-90acd4b063c9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"I'd be happy to help you on your chess journey! To provide better guidance, it would be helpful to know:\\n\\n1. What's your current level in chess? (beginner, intermediate, etc.)\\n2. Do you already know the basic rules and piece movements?\\n3. Are you practicing regularly or just starting out?\\n4. Do you have any specific areas of the game you'd like to focus on (openings, tactics, endgame, etc.)?\\n\\nOnce you share more details about your current chess experience and specific goals, I can provide more targeted advice and help you develop a learning plan. Just let me know, and I'll update my understanding of your chess journey accordingly!\""
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "thread_1 = \"thread-2\"\n",
    "user_id2 = \"User-B\"\n",
    "chat(agent, \n",
    "     \"Hi I'm John, I'm learning chess - could you help me become great??\",\n",
    "     thread_1,\n",
    "     user_id2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "6f972317-4050-4af0-8353-3e1667c977e6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"Based on my memories, I only know that you're interested in chess, which while often considered a mind sport, isn't typically categorized as a traditional sport. I don't have any memories of you mentioning other sports that you like. If you'd like to tell me about any sports you enjoy, I'd be happy to remember that information for future conversations!\""
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chat(agent, \n",
    "     \"Do you remember me liking any sports?\",\n",
    "     thread_1,\n",
    "     user_id2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "1592e7af-54c3-4e1e-bcfe-e5299b1606f5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('agent_memories', 'User-A') {'content': 'User Will is training for a half marathon in 2 months. Goal event timeline: Approximately May 2024.'}\n",
      "('agent_memories', 'User-A') {'content': 'Half Marathon Training Plan for Will:\\n\\nWeek 1-2:\\n- Tuesday: 3 miles easy pace\\n- Thursday: 3 miles with middle mile at tempo pace\\n- Saturday: 4-5 miles long run\\n- Other days: Rest or cross-training\\n\\nWeek 3-4:\\n- Tuesday: 4 miles easy pace\\n- Thursday: 4 miles with tempo intervals\\n- Saturday: 6-7 miles long run\\n- Other days: Rest or cross-training\\n\\nWeek 5-6:\\n- Tuesday: 5 miles easy pace\\n- Thursday: 5 miles with speed work\\n- Saturday: 8-9 miles long run\\n- Other days: Rest or cross-training\\n\\nWeek 7-8:\\n- Tuesday: 5-6 miles easy pace\\n- Thursday: 5-6 miles with tempo runs\\n- Saturday: 10-11 miles long run\\n- Other days: Rest or cross-training\\n\\nFinal 2 weeks:\\n- Begin tapering\\n- Tuesday: 4 miles easy pace\\n- Thursday: 3 miles with light tempo\\n- Saturday (week before race): 6-8 miles\\n- Race week: Light 2-3 mile runs, rest 2 days before race\\n- Race day!\\n\\nKey Guidelines:\\n- Easy pace: Should be able to hold a conversation\\n- Tempo pace: Comfortably hard, about 20-30 seconds faster than easy pace\\n- Cross-training: Swimming, cycling, or strength training\\n- Stay hydrated and maintain proper nutrition\\n- Rest when needed and listen to your body\\n- Gradually increase distance to prevent injury'}\n",
      "('agent_memories', 'User-B') {'content': 'User John is learning chess and wants to become great at it. They are seeking help to improve their chess skills.'}\n"
     ]
    }
   ],
   "source": [
    "items = store.search((\"agent_memories\",))\n",
    "for item in items:\n",
    "    print(item.namespace, item.value)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d8f505cc-736f-4894-a214-1872ec8e17f7",
   "metadata": {},
   "source": [
    "## \"Eager\" memory retrieval\n",
    "\n",
    "We can fetch memories before the first LLM call to simplify its response. Otherwise, it has known and unknown unknowns so will almost always try to search for some subclass of questions."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "dd8ceedf-7c3b-4609-9bb3-542c94f71c66",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langmem import create_manage_memory_tool, create_search_memory_tool\n",
    "from langgraph.config import get_store\n",
    "\n",
    "store = InMemoryStore(\n",
    "    index={\n",
    "        \"dims\": 1536,\n",
    "        \"embed\": \"openai:text-embedding-3-small\"\n",
    "    }\n",
    ")\n",
    "\n",
    "namespace = (\"agent_memories\",)\n",
    "memory_tools = [\n",
    "    create_manage_memory_tool(namespace),\n",
    "    create_search_memory_tool(namespace)\n",
    "]\n",
    "checkpointer = InMemorySaver()\n",
    "\n",
    "def prompt(state):\n",
    "    # Search over memories based on the messages\n",
    "    store = get_store()\n",
    "    items = store.search(namespace, query=state[\"messages\"][-1].content)\n",
    "    memories = \"\\n\\n\".join(str(item) for item in items)\n",
    "    system_msg = {\"role\": \"system\", \"content\": f\"## Memories:\\n\\n{memories}\"}\n",
    "    return [system_msg] + state[\"messages\"]\n",
    "    \n",
    "agent = create_react_agent(\"anthropic:claude-3-5-sonnet-latest\", prompt=prompt, tools=memory_tools, store=store, checkpointer=checkpointer)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "667804de-3b2b-46cd-ac1b-9cd3e01aa9f1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"I've created an 8-week training plan for your half marathon preparation. The plan gradually increases your mileage while incorporating different types of runs and adequate rest periods. Here's a breakdown of the key components:\\n\\n1. Weekly Structure:\\n- 3-4 running days\\n- 2 rest/cross-training days\\n- 1 long run day (typically Saturday)\\n- 1 complete rest or active recovery day (Sunday)\\n\\n2. Types of Runs:\\n- Easy runs: Build base endurance\\n- Interval training: Improve speed and running economy\\n- Long runs: Build endurance and prepare for race distance\\n- Tempo runs: Improve running efficiency\\n\\n3. Progressive Build-up:\\n- Weeks 1-2: Building base mileage\\n- Weeks 3-4: Increasing distance\\n- Weeks 5-6: Peak training weeks\\n- Week 7: Maximum long run\\n- Week 8: Taper week for race preparation\\n\\nThe plan assumes you can already run 3-4 miles comfortably. If this isn't the case, please let me know, and I can adjust the plan accordingly. Also, if you have any specific concerns or constraints (like previous injuries or schedule limitations), I can modify the plan to better suit your needs.\\n\\nWould you like me to elaborate on any specific aspect of the training plan?\""
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "thread_1 = \"thread-1\"\n",
    "chat(agent, \"Hi there, I'm training for a half marathon in 2 months - could you propose a daily training plan to prepare?\", thread_1, None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "078c7701-1a41-4219-8b7d-a3a241afa58a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "I've already stored the detailed training plan in the memories (as shown in the previous interaction), so you'll be able to refer back to it anytime! The memory includes the complete 8-week schedule, including daily workouts and important tips about hydration, rest, and cross-training.\n",
      "\n",
      "Good luck with your half marathon training! Remember to:\n",
      "1. Start gradually and follow the progression\n",
      "2. Listen to your body\n",
      "3. Stay consistent with your training\n",
      "4. Keep hydrated and maintain good nutrition\n",
      "5. Get adequate rest between sessions\n",
      "\n",
      "Feel free to come back anytime if you need to review the training plan or have questions about specific aspects of your training. The detailed plan will be here in the memories ready for you to access!\n"
     ]
    }
   ],
   "source": [
    "print(chat(agent, \"Nice! Wish me luck! Please note down the detailed memories for me :)\", thread_1, None))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "7d3f2ab4-837c-4867-8788-562010cbfa72",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"Let me check your half marathon training plan. Based on your training schedule for Week 3-4, here's what you should be doing:\\n\\nWeek 3 Schedule:\\n- Monday: 4 mile easy run\\n- Tuesday: Cross-training or rest\\n- Wednesday: 5 mile run with intervals (2 min fast, 2 min recover)\\n- Thursday: Rest or light cross-training\\n- Friday: 4 mile easy run\\n- Saturday: 7-8 mile long run\\n- Sunday: Rest or light walk\\n\\nRemember:\\n- During your intervals on Wednesday, alternate between 2 minutes of faster pace and 2 minutes of recovery pace\\n- Your easy runs should be at a comfortable, conversational pace\\n- For your weekend long run, you can choose between 7-8 miles depending on how you're feeling\\n- Listen to your body and make sure to stay hydrated\\n- Cross-training options include swimming, cycling, or strength training\\n\\nIs there anything specific about any of these workouts you'd like me to explain further?\""
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "thread_2 = \"thread-2\"\n",
    "chat(agent, \"What I'm supposed to do for my training this week? It's week 3...\", thread_2, None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d1b7f269-ae7e-4134-86f9-fe2d5dec9e74",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
